// 商品状态 1 待上架 2 上架 3下架"
export const CommodityStatusEnums = [
  { value: 1, label: '待发布', color: 'rgba(82,196,26)' },
  { value: 2, label: '已上架', color: 'rgba(24, 144, 255)' },
  { value: 3, label: '已下架', color: 'rgba(214,214,214)' },
];

// Filter区域 默认为收起状态
export const defaultExpandStatus = false;
// 展开状态下一共有多少个项
export const expandFieldLenth = 4;
// 收起状态下一共有多少项目
export const collapseFieldLenth = 3;

export const getNextActionListSpan = (expandStatus: boolean): number => {
  const totalFieldLength = expandStatus ? expandFieldLenth : collapseFieldLenth;
  if (totalFieldLength < 3) {
    return 3;
  }
  return (4 - (totalFieldLength % 4)) * 3;
};

export const SelectRequestConfig: any = {
  manual: false,
  initialData: [],
  defaultParams: [{ current: 1, pageSize: 10 }, { enable: true }],
  debounceInterval: 800,
  formatResult: (res) => res.list?.map((item) => ({
    value: item.id,
    label: item.name,
    ...item,
  })) || [],
};

export function objectToArray(obj: { [key: string]: string }): Array<{ key: string; value: string }> {
  const arr = [];
  for (const [key, value] of Object.entries(obj)) {
    arr.push({ key, value });
  }
  return arr;
}